import React, { Component } from 'react';
import { connect } from 'dva';
import { Card, Table } from 'antd';

const STORE_NAME = 'publicServerMessage';

@connect(state => ({
  [STORE_NAME]: state[STORE_NAME],
  loading: state.loading,
}))
class publicServerMessage extends Component {
  constructor(props) {
    super(props);
    window.scope = this;
  }

  componentDidMount() {
    this.fetchData();
  }

  getDataFromStore = key => (key ? this.props[STORE_NAME][key] : this.props[STORE_NAME]);

  fetchData() {
    const { dispatch } = this.props;
    dispatch({
      type: `${STORE_NAME}/fetchTableData`,
    });
  }

  columns = [
    {
      title: '姓名',
      key: 'name',
      dataIndex: 'name',
    },
    {
      title: '出生年月',
      key: 'content',
      dataIndex: 'content',
    },
    {
      title: '联系方式',
      key: 'tel',
      dataIndex: 'tel',
    },
    {
      title: '健康状况',
      key: 'status',
      dataIndex: 'status',
    },
    {
      title: '家庭住址',
      key: 'address',
      dataIndex: 'address',
    },
    {
      title: '操作',
      key: 'gener',
      render: () => (
        <span>
          <a>查看</a>
          <a>回复</a>
          <a>删除</a>
        </span>
      ),
    },
  ];

  render() {
    const { columns } = this;
    // const { tableDataSource: dataSource } = this.getDataFromStore();
    // const {
    //   effects: {
    //     'publicServerMessage/fetchTableData': loading,
    //   },
    // } = this.props.loading;

    return (
      <div>
        <Card title="司机管理">
          <Table
            bordered
            columns={columns}
            // dataSource={dataSource}
          />
        </Card>
      </div>
    );
  }
}

export default publicServerMessage;
